package android.framework.provider;

import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.framework.db.DBHelper;
import android.framework.db.DBHelperUtil;
import android.net.Uri;

public class Provider extends ContentProvider {
    DBHelperUtil dbHelperUtil;
	@Override
	public int delete(Uri arg0, String arg1, String[] arg2) {
		int id=dbHelperUtil.delete(DBHelper.provider_tb, arg1, arg2);
		if(id!=0)return id;
		return 0;
	}

	@Override
	public String getType(Uri uri) {
		return null;
	}

	@Override
	public Uri insert(Uri uri, ContentValues values) {
		dbHelperUtil.insert(DBHelper.provider_tb, "id", values);
		return null;
	}

	@Override
	public boolean onCreate() {
		dbHelperUtil = new DBHelperUtil(getContext());
		return true;
	}

	@Override
	public Cursor query(Uri uri, String[] projection, String selection,
			String[] selectionArgs, String sortOrder) {
		Cursor c=dbHelperUtil.query(DBHelper.provider_tb,projection, selection, selectionArgs, null, null, sortOrder,null);
		return c;
	}

	@Override
	public int update(Uri uri, ContentValues values, String selection,
			String[] selectionArgs) {
		int id=dbHelperUtil.update(DBHelper.provider_tb, values, selection, selectionArgs);
		if(id!=0)return id;
		return 0;
	}

}

